package org.huawei260.TiKu.ODsuanfa;

/**
 * @Author: qingle
 * @Date: 2024/10/28-16:11
 * @Description: 2819 【哈希表】2024D掌握单词个数
 * @version: 1.0
 */
import java.util.Scanner;
public class D_2024D_2819__哈希表掌握单词个数 {

//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();

			String[] words = new String[n];
			for (int i = 0; i < n; i++) {
				words[i] = sc.next();
			}

			String chars = sc.next();

			System.out.println(getResult(words, n, chars));
		}

		public static int getResult(String[] words, int n, String chars) {
			int ans = 0;

			// 统计chars字符串中各字符的数量
			int[] cnt_chars = charStatistic(chars);

			for (int i = 0; i < n; i++) {
				int diff = 0;

				// 统计word字符串中各字符的数量
				int[] cnt_word = charStatistic(words[i]);

				for (int j = 0; j < 128; j++) {
					// 记录word的某字符超过chars的对应字符出现的数量
					diff += Math.max(cnt_word[j] - cnt_chars[j], 0);
				}

				if (diff <= cnt_chars['?']) {
					ans++;
					// System.out.println(words[i]);
				}
			}

			return ans;
		}

		public static int[] charStatistic(String s) {
			int[] cnts = new int[128];

			for (int i = 0; i < s.length(); i++) {
				char c = s.charAt(i);
				cnts[c] += 1;
			}

			return cnts;
		}
	}